
/*

___________________________________________________________________________
Income mobility analysis includes the following items

_________
Main text

Figure 4: Average income trajectories of incorporated entrepreneurs and wage earners

Figure 5: Differences in income trajectories between entrepreneurs and wage earners by individual and parental income

Figure 6: Entrepreneurship and income mobility

_________
Appendix

Figure A8: Income trajectories by firm survival five years after establishment

Figure A9: Composition of market income sources by individual income

Figure B1: Average market income trajectories when accounting for retained earnings

Figure B2: Differences in income trajectories between entrepreneurs and wage earners by individual and parental income: Market income

Figure B3: Differences in income trajectories between entrepreneurs and wage earners by individual and parental income: Market income with retained earnings

Table B1: Sensitivity of the gains from entrepreneurship to the estimation sample

Figure B4: Disposable income trajectories using a balanced panel of individuals

Figure B5: Gains in disposable income by industry of the new incorporated business

*/









/*
________________________________________________________________________________
Main text
*/

/*
________________________________________________________________________________
Figure 4: Average income trajectories of incorporated entrepreneurs and wage earners
*/

use "$output\04_incomemobility\fig4", clear

/*
Panel A
*/

gen nro_ie=nro+0.1
gen nro_we=nro-0.1
order nro nro_ie nro_we

twoway scatter base nro_we, mc(gs10) msymbol(oh) graphr(c(white)) scheme(s2mono) ytitle("Log income", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) title("{it:Panel A: Entrepreneurs and wage earners separately}", size(medsmall) color(black) nobox) xtitle("", size(medium)) xtitle(, color(black)) legend(ring(0) rowg(0.25) bplace(seast)) ysize(3.5) name(A, replace)
addplot A: line base nro_we, lc(gs10) lp(solid) 
addplot A: scatter lvl_ie nro_ie, mc(maroon) msymbol(sh)
addplot A: line lvl_ie nro_ie, lc(maroon) lp(solid) xlabel(-5(1)10) ysc(range(-0.26 0.45)) ylabel(-0.2(0.2)0.4, angle(0)) legend(order(3 "Entrepreneurs" 1 "Wage earners") cols(1) size(small))

/*
Panel B
*/

rename eff_ie_noc eff
gen eff_lo = eff - 1.96 * eff_ie_se_noc
gen eff_up = eff + 1.96 * eff_ie_se_noc
twoway rcap eff_lo eff_up nro, col(gs2) || line eff nro, lc(gs2) lp(solid) || scatter eff nro, mc(gs2) msymbol(sh) || , graphr(c(white)) scheme(s2mono) ytitle("{it:IE-WE (log income)}", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) title("{it:Panel B: Difference between entrepreneurs and wage earners}", size(medsmall) color(black) nobox) xtitle("", size(medium)) xtitle(, color(black)) legend(ring(0) bplace(seast) rowg(0.25)) ysize(3.5) name(B, replace)
drop eff eff_lo eff_up

preserve
replace nro=nro+0.2
rename b_cs eff
gen eff_lo = eff - 1.96 * se_cs
gen eff_up = eff + 1.96 * se_cs
addplot B: rcap eff_lo eff_up nro, col(gs12%75) || line eff nro, lc(gs12) lp(solid) || scatter eff nro, mc(gs12%75) msymbol(t)
restore

preserve
replace nro=nro+0.1
rename b_bjs eff
gen eff_lo = eff - 1.96 * se_bjs
gen eff_up = eff + 1.96 * se_bjs
addplot B: rcap eff_lo eff_up nro, col(gs12%75) || line eff nro, lc(gs12) lp(solid) || scatter eff nro, mc(gs12%75) msymbol(th)
restore

preserve
replace nro=nro-0.1
rename eff_ie eff
gen eff_lo = eff - 1.96 * eff_ie_se
gen eff_up = eff + 1.96 * eff_ie_se
addplot B: rcap eff_lo eff_up nro, col(gs2) || line eff nro, lc(gs2) lp(solid) || scatter eff nro, mc(gs2) msymbol(d) || , xlabel(-5(1)10) ysc(range(-0.1 0.24)) ylabel(-0.1(0.1)0.2, angle(0)) legend(order(3 "OLS without controls" 12 "OLS with controls" 9 "CS with controls" 6 "BJS with controls") cols(1) size(small))
restore

/*
Panel C
*/

twoway scatter cem_lvl_ie nro_ie, mc(maroon) msymbol(sh) || , graphr(c(white)) scheme(s2mono)	ytitle("Log income", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) title("{it:Panel C: Entrepreneurs and wage earners separately & matched}", size(medsmall) color(black) nobox) xtitle("", size(medium)) xtitle(, color(black)) legend(ring(0) pos(4) rowg(0.25)) ysize(3.5) name(C, replace)
addplot C: line cem_lvl_ie nro_ie, lc(maroon) lp(solid)

addplot C: scatter cem_base nro_we, mc(gs10) msymbol(oh)
addplot C: line cem_base nro_we, lc(gs10) lp(solid) xlabel(-5(1)10) ysc(range(-0.26 0.45)) ylabel(-0.2(0.2)0.4, angle(0)) legend(order(1 "Entrepreneurs" 3 "Wage earners") cols(1) size(small))

/*
Panel D
*/

rename nro_ie nro_yes
rename nro_we nro_no

twoway scatter lvl_ie_peyes nro_yes, mc(maroon) msymbol(s) || , graphr(c(white)) scheme(s2mono) ytitle("Log income", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) title("{it:Panel D: Entrepreneurs by parental entrepreneurship}", size(medsmall) color(black) nobox) xtitle("", size(medium)) xtitle(, color(black)) legend(ring(0) pos(4) rowg(0.25)) ysize(3.5) name(D, replace)
addplot D: line lvl_ie_peyes nro_yes, lc(maroon) lp(solid)
addplot D: scatter lvl_ie_peno nro_no, mc(maroon) msymbol(sh)
addplot D: line lvl_ie_peno nro_no, lc(maroon) lp(solid) xlabel(-5(1)10) ysc(range(-0.26 0.45)) ylabel(-0.2(0.2)0.4, angle(0)) legend(order(1 "Parent entrepreneur: Yes" 3 "Parent entrepreneur: No") cols(1) size(small))

/*
Combine the four
*/

gr combine A B C D, graphr(c(white)) col(2) ysize(3.1) note("Years since transition into entrepreneurship or pseudo-start", pos(6) size(small))  name(fig4, replace)
gr drop A B C D
graph export "$figs\fig4.eps", as(eps) preview(off) replace

/*
________________________________________________________________________________
Figure 5: Differences in income trajectories between entrepreneurs and wage earners by individual and parental income
*/

use "$output\04_incomemobility\fig5", clear
foreach var of varlist b1_ie-se25_we {
	gen `var'_m1=`var'[5]
}
foreach var of varlist b1_ie-se25_we {
	replace `var'=`var'-`var'_m1
}
drop *m1

* Point estimates
forval i= 1(1)25{
	gen diff_`i'=b`i'_ie-b`i'_we
}

* Confidence intervals
forval i= 1(1)25{
	gen lo_`i'_ie=b`i'_ie-1.96*se`i'_ie
	gen up_`i'_ie=b`i'_ie+1.96*se`i'_ie
	gen lo_`i'_we=b`i'_we-1.96*se`i'_we
	gen up_`i'_we=b`i'_we+1.96*se`i'_we
}
forval i= 1(1)25{
	gen diff_lo_`i'=lo_`i'_ie-lo_`i'_we
	gen diff_up_`i'=up_`i'_ie-up_`i'_we
}

* Make some room in the timeline
gen event_b=event-0.1
gen event_t=event+0.1

* Individual: P1-P20
twoway rcap diff_lo_1 diff_up_1 event_b, col(gs6) || scatter diff_1 event_b, mc(gs6) ms(sh) || line diff_1 event_b, lc(gs6) lp(solid) || line diff_2 event, lc(gs12) lp(solid) || scatter diff_2 event, mc(gs12) ms(x) || scatter diff_3 event, mc(gs12) ms(x) || scatter diff_4 event, mc(gs12) ms(x) || line diff_3 event, lc(gs12) lp(solid) || line diff_4 event, lc(gs12) lp(solid) || rcap diff_lo_5 diff_up_5 event_t, col(gs6) || scatter diff_5 event_t, mc(gs2) ms(d) || line diff_5 event_t, lc(gs2) lp(solid) || , graphr(c(white)) scheme(s2mono) title("{it:Individual P1-P20}", size(medium) color(black) nobox) ytitle("{it:IE-WE (log income)}", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) xtitle("", size(medium)) xtitle(, color(black)) xlabel(-5(1)10) ysc(range(-0.2 0.45)) ylabel(-0.2(0.2)0.4, angle(0)) aspect(0.6) legend(order(2 "Parent P1-P20" 5 "Parent P21-P80" 11 "Parent P81-P100") region(style(none)) cols(1) ring(0) bplace(seast) rowg(0.1)) name(ind_p1p20, replace)
* Individual: P21-P40
twoway rcap diff_lo_6 diff_up_6 event_b, col(gs6) || scatter diff_6 event_b, mc(gs6) ms(sh) || line diff_6 event_b, lc(gs6) lp(solid) || line diff_7 event, lc(gs12) lp(solid) || scatter diff_7 event, mc(gs12) ms(x) || scatter diff_8 event, mc(gs12) ms(x) || scatter diff_9 event, mc(gs12) ms(x) || line diff_8 event, lc(gs12) lp(solid) || line diff_9 event, lc(gs12) lp(solid) || rcap diff_lo_10 diff_up_10 event_t, col(gs6) || scatter diff_10 event_t, mc(gs2) ms(d) || line diff_10 event_t, lc(gs2) lp(solid) || , graphr(c(white)) scheme(s2mono) title("{it:Individual P21-P40}", size(medium) color(black) nobox) ytitle("{it:IE-WE (log income)}", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) xtitle("", size(medium)) xtitle(, color(black)) xlabel(-5(1)10) ysc(range(-0.2 0.45)) ylabel(-0.2(0.2)0.4, angle(0)) aspect(0.6) legend(order(2 "Parent P1-P20" 5 "Parent P21-P80" 11 "Parent P81-P100") region(style(none)) cols(1) ring(0) bplace(seast) rowg(0.1)) name(ind_p21p40, replace)
* Individual: P41-P60
twoway rcap diff_lo_11 diff_up_11 event_b, col(gs6) || scatter diff_11 event_b, mc(gs6) ms(sh) || line diff_11 event_b, lc(gs6) lp(solid) || line diff_12 event, lc(gs12) lp(solid) || scatter diff_12 event, mc(gs12) ms(x) || scatter diff_13 event, mc(gs12) ms(x) || scatter diff_14 event, mc(gs12) ms(x) || line diff_13 event, lc(gs12) lp(solid) || line diff_14 event, lc(gs12) lp(solid) || rcap diff_lo_15 diff_up_15 event_t, col(gs6) || scatter diff_15 event_t, mc(gs2) ms(d) || line diff_15 event_t, lc(gs2) lp(solid) || , graphr(c(white)) scheme(s2mono) title("{it:Individual P41-P60}", size(medium) color(black) nobox) ytitle("{it:IE-WE (log income)}", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) xtitle("", size(medium)) xtitle(, color(black)) xlabel(-5(1)10) ysc(range(-0.2 0.45)) ylabel(-0.2(0.2)0.4, angle(0)) aspect(0.6) legend(order(2 "Parent P1-P20" 5 "Parent P21-P80" 11 "Parent P81-P100") region(style(none)) cols(1) ring(0) bplace(seast) rowg(0.1)) name(ind_p41p60, replace)
* Individual: P61-P80
twoway rcap diff_lo_16 diff_up_16 event_b, col(gs6) || scatter diff_16 event_b, mc(gs6) ms(sh) || line diff_16 event_b, lc(gs6) lp(solid) || line diff_17 event, lc(gs12) lp(solid) || scatter diff_17 event, mc(gs12) ms(x) || scatter diff_18 event, mc(gs12) ms(x) || scatter diff_19 event, mc(gs12) ms(x) || line diff_18 event, lc(gs12) lp(solid) || line diff_19 event, lc(gs12) lp(solid) || rcap diff_lo_20 diff_up_20 event_t, col(gs6) || scatter diff_20 event_t, mc(gs2) ms(d) || line diff_20 event_t, lc(gs2) lp(solid) || , graphr(c(white)) scheme(s2mono) title("{it:Individual P61-P80}", size(medium) color(black) nobox) ytitle("{it:IE-WE (log income)}", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) xtitle("", size(medium)) xtitle(, color(black)) xlabel(-5(1)10) ysc(range(-0.2 0.45)) ylabel(-0.2(0.2)0.4, angle(0)) aspect(0.6) legend(order(2 "Parent P1-P20" 5 "Parent P21-P80" 11 "Parent P81-P100") region(style(none)) cols(1) ring(0) bplace(seast) rowg(0.1)) name(ind_p61p80, replace)
* Individual: P81-P100
twoway rcap diff_lo_21 diff_up_21 event_b, col(gs6) || scatter diff_21 event_b, mc(gs6) ms(sh) || line diff_21 event_b, lc(gs6) lp(solid) || line diff_22 event, lc(gs12) lp(solid) || scatter diff_22 event, mc(gs12) ms(x) || scatter diff_23 event, mc(gs12) ms(x) || scatter diff_24 event, mc(gs12) ms(x) || line diff_23 event, lc(gs12) lp(solid) || line diff_24 event, lc(gs12) lp(solid) || rcap diff_lo_25 diff_up_25 event_t, col(gs6) || scatter diff_25 event_t, mc(gs2) ms(d) || line diff_25 event_t, lc(gs2) lp(solid) || , graphr(c(white)) scheme(s2mono) title("{it:Individual P81-P100}", size(medium) color(black) nobox) ytitle("{it:IE-WE (log income)}", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) xtitle("", size(medium)) xtitle(, color(black)) xlabel(-5(1)10) ysc(range(-0.2 0.45)) ylabel(-0.2(0.2)0.4, angle(0)) aspect(0.6) legend(order(2 "Parent P1-P20" 5 "Parent P21-P80" 11 "Parent P81-P100") region(style(none)) cols(1) ring(0) bplace(seast) rowg(0.1)) name(ind_p81p100, replace)

* Combine
gr combine ind_p1p20 ind_p21p40 ind_p41p60, graphr(c(white)) col(3) name(row1, replace)
gr combine ind_p61p80 ind_p81p100, graphr(c(white)) col(2) graphregion(margin(l+40 r+40)) name(row2, replace)
gr combine row1 row2, graphr(c(white)) col(1) ysize(2.5) title("", size(small) color(black) nobox) note("Years since transition into entrepreneurship or pseudo-start", pos(6) size(small)) name(fig5, replace)
gr drop ind_p1p20 ind_p21p40 ind_p41p60 ind_p61p80 ind_p81p100 row1 row2
graph export "$figs\fig5.eps", as(eps) preview(off) replace

/*
________________________________________________________________________________
Figure 6: Entrepreneurship and income mobility
*/

/*
Panel A
*/

use "$output\04_incomemobility\fig6_A", clear

twoway scatter tm1_shr rank, mc(maroon*.6) msymbol(d) graphr(c(white)) scheme(s2mono) ytitle("Share of entrepreneurs (%)", size(medsmall)) title("{it:Panel A: Income ranks of incorporated entrepreneurs}", size(medium) color(black) nobox) xtitle("Individual income rank at {it:t-1}", size(medium)) xtitle(, color(black)) legend(pos(10) ring(0) cols(1) rowg(0.2) symx(4) region(style(none))) ysize(3) name(fig6_A, replace)

* t+10
addplot fig6_A: scatter tp10_shr rank, mc(maroon*.8) msymbol(Oh) 

* Pooled cross-sections 2006-2016
addplot fig6_A: line all_shr rank, lc(gs2) lp(solid) legend(order(1 "Rank at {it:t-1}" 2 "Rank at {it:t+10}" 3 "Rank, all 2006-2016")) xlabel(50(10)100) ysc(range(0 12)) ylabel(0(3)12, angle(0))

* Save
graph export "$figs\fig6_A.eps", as(eps) preview(off) replace

/*
Panels B and C
*/

use "$output\04_incomemobility\fig6_BC", clear

* Label values
replace vtile=vtile+0.05
gen rank_l = vtile-0.1
gen rank_r = vtile+0.1
gen rank_ll = vtile-0.2
gen rank_rr = vtile+0.2
label define ranklabel 1 "P1-P5" 2 "P6-P10" 3 "P11-P15" 4 "P16-P20" 5 "P21-P25" 6 "P26-P30" 7 "P31-P35" 8 "P36-P40" 9 "P41-P45" 10 "P46-P50" 11 "P51-P55" 12 "P56-P60" 13 "P61-P65" 14 "P66-P70" 15 "P71-P75" 16 "P76-P80" 17 "P81-P85" 18 "P86-P90" 19 "P91-P95" 20 "P96-P100"
label values rank_l ranklabel

* Top 1%
twoway scatter top1_ie rank_l, mc(maroon) msymbol(sh) || rcap top1_ie_95lo top1_ie_95up rank_l, col(maroon%50) || scatter top1_we rank_rr, mc(gs6) msymbol(oh) || rcap top1_we_95lo top1_we_95up rank_rr, col(gs6%50) || , graphr(c(white)) scheme(s2mono) ytitle("Pr(Top 1% at {it:t+10})", size(medsmall)) title("{it:Panel B: Probability to reach the top 1% by individual t-1 income}", size(medium) color(black) nobox) xtitle("", size(medium)) legend(ring(0) pos(11) rowg(0.2) colg(1) order(1 "Entrepreneurs" /*5 "with controls" */3 "Wage earners"/* 7 "with controls"*/) region(style(none)) size(medsmall) cols(1)) xtitle(, color(black)) xsc(range(1 20)) xlab(1(1)20, valuelabel angle(45)) ysc(range(0 0.4)) ylabel(0(0.1)0.4, angle(0)) ysize(4) name(B, replace)

* Top 10%
twoway scatter top10_ie rank_l, mc(maroon) msymbol(sh) || rcap top10_ie_95lo top10_ie_95up rank_l, col(maroon%50) || scatter top10_we rank_rr, mc(gs6) msymbol(oh) || rcap top10_we_95lo top10_we_95up rank_rr, col(gs6%50) || , graphr(c(white)) scheme(s2mono) ytitle("Pr(Top 10% at {it:t+10})", size(medsmall)) title("{it:Panel C: Probability to reach the top 10% by individual t-1 income}", size(medium) color(black) nobox) xtitle("", size(medium)) legend(ring(0) pos(11) rowg(0.2) colg(0.2) order(1 "Entrepreneurs" /*5 "with controls" */3 "Wage earners"/* 7 "with controls"*/) region(style(none)) size(medsmall) cols(1)) xtitle(, color(black)) xsc(range(1 20)) xlab(1(1)20, valuelabel angle(45)) ysc(range(0 0.8)) ylabel(0(0.2)0.8, angle(0)) ysize(4) name(C, replace)

* Combine
gr combine B C, graphr(c(white)) col(2) note("Individual income rank at {it:t-1}", pos(6) size(medsmall)) ysize(2.5) name(fig6_BC, replace)
gr drop B C
graph export "$figs\fig6_BC.eps", as(eps) preview(off) replace

/*
Panels D and E
*/

use "$output\04_incomemobility\fig6_DE", clear

* Label values
replace vtile=vtile+0.05
gen rank_l = vtile-0.1
gen rank_r = vtile+0.1
gen rank_ll = vtile-0.2
gen rank_rr = vtile+0.2
label define ranklabel 1 "P1-P5" 2 "P6-P10" 3 "P11-P15" 4 "P16-P20" 5 "P21-P25" 6 "P26-P30" 7 "P31-P35" 8 "P36-P40" 9 "P41-P45" 10 "P46-P50" 11 "P51-P55" 12 "P56-P60" 13 "P61-P65" 14 "P66-P70" 15 "P71-P75" 16 "P76-P80" 17 "P81-P85" 18 "P86-P90" 19 "P91-P95" 20 "P96-P100"
label values rank_l ranklabel

* Top 1%
twoway scatter top1_ie rank_l, mc(maroon) msymbol(sh) || rcap top1_ie_95lo top1_ie_95up rank_l, col(maroon%50) || scatter top1_we rank_rr, mc(gs6) msymbol(oh) || rcap top1_we_95lo top1_we_95up rank_rr, col(gs6%50) || , graphr(c(white)) scheme(s2mono) ytitle("Pr(Top 1% at {it:t+10})", size(medsmall)) title("{it:Panel D: Probability to reach the top 1% by parental income}", size(medium) color(black) nobox) xtitle("", size(medium)) legend(ring(0) pos(11) rowg(0.2) colg(1) order(1 "Entrepreneurs" /*5 "with controls" */3 "Wage earners"/* 7 "with controls"*/) region(style(none)) size(medsmall) cols(1)) xtitle(, color(black)) xsc(range(1 20)) xlab(1(1)20, valuelabel angle(45)) ysc(range(0 0.4)) ylabel(0(0.1)0.4, angle(0)) ysize(4) name(D, replace)

* Top 10%
twoway scatter top10_ie rank_l, mc(maroon) msymbol(sh) || rcap top10_ie_95lo top10_ie_95up rank_l, col(maroon%50) || scatter top10_we rank_rr, mc(gs6) msymbol(oh) || rcap top10_we_95lo top10_we_95up rank_rr, col(gs6%50) || , graphr(c(white)) scheme(s2mono) ytitle("Pr(Top 10% at {it:t+10})", size(medsmall)) title("{it:Panel E: Probability to reach the top 10% by parental income}", size(medium) color(black) nobox) xtitle("", size(medium)) legend(ring(0) pos(11) rowg(0.2) colg(0.2) order(1 "Entrepreneurs" /*5 "with controls" */3 "Wage earners"/* 7 "with controls"*/) region(style(none)) size(medsmall) cols(1)) xtitle(, color(black)) xsc(range(1 20)) xlab(1(1)20, valuelabel angle(45)) ysc(range(0 0.8)) ylabel(0(0.2)0.8, angle(0)) ysize(4) name(E, replace)

* Combine
gr combine D E, graphr(c(white)) col(2) note("Parental income rank", pos(6) size(medsmall)) ysize(2.5) name(fig6_DE, replace)
gr drop D E
graph export "$figs\fig6_DE.eps", as(eps) preview(off) replace









/*
________________________________________________________________________________
Appendix
*/

/*
Figure A8: Income trajectories by firm survival five years after establishment
*/

use "$output\04_incomemobility\figA8", clear
merge 1:1 nro using "$output\04_incomemobility\fig4", keepusing(base)
gen nro_yes=nro+0.1
gen nro_no=nro-0.1
order nro nro_yes nro_no

twoway scatter lvl_ie_surv5no nro_no, mc(maroon) msymbol(sh) || , graphr(c(white)) scheme(s2mono) ytitle("Log income", size(medium)) ytitle(, color(black)) xline(0, lp(dash)) title("", size(medium) color(black) nobox) xtitle("Years since transition into entrepreneurship or pseudo-start", size(medium)) xtitle(, color(black)) legend(ring(0) bplace(seast)) ysize(3) name(figA8, replace)
addplot figA8: line lvl_ie_surv5no nro_no, lc(maroon) lp(solid)
addplot figA8: scatter base nro, mc(gs10) msymbol(oh)
addplot figA8: line base nro, lc(gs10) lp(solid)
addplot figA8: scatter lvl_ie_surv5yes nro_yes, mc(maroon) msymbol(s)
addplot figA8: line lvl_ie_surv5yes nro_yes, lc(maroon) lp(solid) xlabel(-5(1)10) ysc(range(-0.22 0.42)) ylabel(-0.2(0.2)0.4, angle(0)) legend(order(5 "Main owner after the first 5 years" 1 "Not main owner after the first 5 years" 3 "Wage earners") region(style(none)) cols(1))

graph export "$figs\figA8.eps", as(eps) preview(off) replace

/*
Figure A9: Composition of market income sources by individual income
*/

use "$output\04_incomemobility\figA9", clear
gen nr=_n

label define ptile_lbl 1 "1-90" 2 "91" 3 "92" 4 "93" 5 "94" 6 "95" 7 "96" 8 "97" 9 "98" 10 "99" 11 "99-99.9" 12 "99.9-100" 
label values nr ptile_lbl

twoway line mkti_shr_l nr, col(navy) lp(solid) || scatter mkti_shr_l nr, mc(navy) msymbol(o) || , graphr(c(white)) scheme(s2mono) ytitle("Share of income source", size(medsmall)) xtitle("Market income rank", size(medium)) ysize(3.5) legend(ring(0) bplace(west)) name(figA9, replace)
addplot figA9: line mkti_shr_ec nr, col(maroon) lp(solid) || scatter mkti_shr_ec nr, mc(maroon) msymbol(t)
addplot figA9: line mkti_d_are_1_shr_l nr, col(navy) lp(solid) || scatter mkti_d_are_1_shr_l nr, mc(navy) msymbol(oh)
addplot figA9: line mkti_d_are_1_shr_ec nr, col(maroon) lp(solid) || scatter mkti_d_are_1_shr_ec nr, mc(maroon) msymbol(th) ||, xlabel(1(1)12, valuelabel angle(45)) ysc(range(0 1)) ylabel(0(0.2)1, angle(0)) legend(order(2 "Wages (retained earnings excluded)" 4 "Business income & other capital income (retained earnings excluced)" 6 "Wages (retained earnings included)" 8 "Business income & other capital income (retained earnings included)") region(style(none)) cols(1))

graph export "$figs\figA9.eps", as(eps) preview(off) replace

/*
Figure B1: Average market income trajectories when accounting for retained earnings
*/

use "$output\04_incomemobility\figB1", clear

gen nro_ie=nro+0.1
gen nro_we=nro-0.1
order nro nro_ie nro_we

twoway scatter base_mkti nro_we, mc(gs10) msymbol(oh) graphr(c(white)) scheme(s2mono) ytitle("Log income", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) title("", size(medsmall) color(black) nobox) xtitle("Years since transition into entrepreneurship or pseudo-start", size(medium)) xtitle(, color(black)) legend(ring(0) rowg(0.25) bplace(seast)) ysize(3.5) name(figB1, replace)
addplot figB1: line base_mkti nro_we, lc(gs10) lp(solid) 
addplot figB1: scatter lvl_ie_re nro_ie, mc(maroon) msymbol(th)
addplot figB1: line lvl_ie_re nro_ie, lc(maroon) lp(dash)
addplot figB1: scatter lvl_ie_mkti nro_ie, mc(maroon) msymbol(sh)
addplot figB1: line lvl_ie_mkti nro_ie, lc(maroon) lp(solid) xlabel(-5(1)10) ysc(range(-0.3 0.62)) ylabel(-0.3(0.15)0.6, angle(0)) legend(order(5 "Entrepreneurs, market income" 3 "Market income with retained earnings" 1 "Wage earners, market income") cols(1) ysize(3) size(small))

graph export "$figs\figB1.eps", as(eps) preview(off) replace

/*
Figure B2: Differences in income trajectories between entrepreneurs and wage earners by individual and parental income: Market income
*/

use "$output\04_incomemobility\figB2", clear
foreach var of varlist b1_ie-se25_we {
	gen `var'_m1=`var'[5]
}
foreach var of varlist b1_ie-se25_we {
	replace `var'=`var'-`var'_m1
}
drop *m1

* Point estimates
forval i= 1(1)25{
	gen diff_`i'=b`i'_ie-b`i'_we
}

* Confidence intervals
forval i= 1(1)25{
	gen lo_`i'_ie=b`i'_ie-1.96*se`i'_ie
	gen up_`i'_ie=b`i'_ie+1.96*se`i'_ie
	gen lo_`i'_we=b`i'_we-1.96*se`i'_we
	gen up_`i'_we=b`i'_we+1.96*se`i'_we
}
forval i= 1(1)25{
	gen diff_lo_`i'=lo_`i'_ie-lo_`i'_we
	gen diff_up_`i'=up_`i'_ie-up_`i'_we
}

* Make some room in the timeline
gen event_b=event-0.1
gen event_t=event+0.1

* Individual: P1-P20
twoway rcap diff_lo_1 diff_up_1 event_b, col(gs6) || scatter diff_1 event_b, mc(gs6) ms(sh) || line diff_1 event_b, lc(gs6) lp(solid) || line diff_2 event, lc(gs12) lp(solid) || scatter diff_2 event, mc(gs12) ms(x) || scatter diff_3 event, mc(gs12) ms(x) || scatter diff_4 event, mc(gs12) ms(x) || line diff_3 event, lc(gs12) lp(solid) || line diff_4 event, lc(gs12) lp(solid) || rcap diff_lo_5 diff_up_5 event_t, col(gs6) || scatter diff_5 event_t, mc(gs2) ms(d) || line diff_5 event_t, lc(gs2) lp(solid) || , graphr(c(white)) scheme(s2mono) title("{it:Individual P1-P20}", size(medium) color(black) nobox) ytitle("{it:IE-WE (log income)}", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) xtitle("", size(medium)) xtitle(, color(black)) xlabel(-5(1)10) ysc(range(-0.4 0.6)) ylabel(-0.4(0.2)0.6, angle(0)) aspect(0.6) legend(order(2 "Parent P1-P20" 5 "Parent P21-P80" 11 "Parent P81-P100") region(style(none)) cols(1) ring(0) bplace(seast) rowg(0.1)) name(ind_p1p20, replace)
* Individual: P21-P40
twoway rcap diff_lo_6 diff_up_6 event_b, col(gs6) || scatter diff_6 event_b, mc(gs6) ms(sh) || line diff_6 event_b, lc(gs6) lp(solid) || line diff_7 event, lc(gs12) lp(solid) || scatter diff_7 event, mc(gs12) ms(x) || scatter diff_8 event, mc(gs12) ms(x) || scatter diff_9 event, mc(gs12) ms(x) || line diff_8 event, lc(gs12) lp(solid) || line diff_9 event, lc(gs12) lp(solid) || rcap diff_lo_10 diff_up_10 event_t, col(gs6) || scatter diff_10 event_t, mc(gs2) ms(d) || line diff_10 event_t, lc(gs2) lp(solid) || , graphr(c(white)) scheme(s2mono) title("{it:Individual P21-P40}", size(medium) color(black) nobox) ytitle("{it:IE-WE (log income)}", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) xtitle("", size(medium)) xtitle(, color(black)) xlabel(-5(1)10) ysc(range(-0.4 0.6)) ylabel(-0.4(0.2)0.6, angle(0)) aspect(0.6) legend(order(2 "Parent P1-P20" 5 "Parent P21-P80" 11 "Parent P81-P100") region(style(none)) cols(1) ring(0) bplace(seast) rowg(0.1)) name(ind_p21p40, replace)
* Individual: P41-P60
twoway rcap diff_lo_11 diff_up_11 event_b, col(gs6) || scatter diff_11 event_b, mc(gs6) ms(sh) || line diff_11 event_b, lc(gs6) lp(solid) || line diff_12 event, lc(gs12) lp(solid) || scatter diff_12 event, mc(gs12) ms(x) || scatter diff_13 event, mc(gs12) ms(x) || scatter diff_14 event, mc(gs12) ms(x) || line diff_13 event, lc(gs12) lp(solid) || line diff_14 event, lc(gs12) lp(solid) || rcap diff_lo_15 diff_up_15 event_t, col(gs6) || scatter diff_15 event_t, mc(gs2) ms(d) || line diff_15 event_t, lc(gs2) lp(solid) || , graphr(c(white)) scheme(s2mono) title("{it:Individual P41-P60}", size(medium) color(black) nobox) ytitle("{it:IE-WE (log income)}", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) xtitle("", size(medium)) xtitle(, color(black)) xlabel(-5(1)10) ysc(range(-0.4 0.6)) ylabel(-0.4(0.2)0.6, angle(0)) aspect(0.6) legend(order(2 "Parent P1-P20" 5 "Parent P21-P80" 11 "Parent P81-P100") region(style(none)) cols(1) ring(0) bplace(seast) rowg(0.1)) name(ind_p41p60, replace)
* Individual: P61-P80
twoway rcap diff_lo_16 diff_up_16 event_b, col(gs6) || scatter diff_16 event_b, mc(gs6) ms(sh) || line diff_16 event_b, lc(gs6) lp(solid) || line diff_17 event, lc(gs12) lp(solid) || scatter diff_17 event, mc(gs12) ms(x) || scatter diff_18 event, mc(gs12) ms(x) || scatter diff_19 event, mc(gs12) ms(x) || line diff_18 event, lc(gs12) lp(solid) || line diff_19 event, lc(gs12) lp(solid) || rcap diff_lo_20 diff_up_20 event_t, col(gs6) || scatter diff_20 event_t, mc(gs2) ms(d) || line diff_20 event_t, lc(gs2) lp(solid) || , graphr(c(white)) scheme(s2mono) title("{it:Individual P61-P80}", size(medium) color(black) nobox) ytitle("{it:IE-WE (log income)}", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) xtitle("", size(medium)) xtitle(, color(black)) xlabel(-5(1)10) ysc(range(-0.4 0.6)) ylabel(-0.4(0.2)0.6, angle(0)) aspect(0.6) legend(order(2 "Parent P1-P20" 5 "Parent P21-P80" 11 "Parent P81-P100") region(style(none)) cols(1) ring(0) bplace(seast) rowg(0.1)) name(ind_p61p80, replace)
* Individual: P81-P100
twoway rcap diff_lo_21 diff_up_21 event_b, col(gs6) || scatter diff_21 event_b, mc(gs6) ms(sh) || line diff_21 event_b, lc(gs6) lp(solid) || line diff_22 event, lc(gs12) lp(solid) || scatter diff_22 event, mc(gs12) ms(x) || scatter diff_23 event, mc(gs12) ms(x) || scatter diff_24 event, mc(gs12) ms(x) || line diff_23 event, lc(gs12) lp(solid) || line diff_24 event, lc(gs12) lp(solid) || rcap diff_lo_25 diff_up_25 event_t, col(gs6) || scatter diff_25 event_t, mc(gs2) ms(d) || line diff_25 event_t, lc(gs2) lp(solid) || , graphr(c(white)) scheme(s2mono) title("{it:Individual P81-P100}", size(medium) color(black) nobox) ytitle("{it:IE-WE (log income)}", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) xtitle("", size(medium)) xtitle(, color(black)) xlabel(-5(1)10) ysc(range(-0.4 0.6)) ylabel(-0.4(0.2)0.6, angle(0)) aspect(0.6) legend(order(2 "Parent P1-P20" 5 "Parent P21-P80" 11 "Parent P81-P100") region(style(none)) cols(1) ring(0) bplace(seast) rowg(0.1)) name(ind_p81p100, replace)

* Combine
gr combine ind_p1p20 ind_p21p40 ind_p41p60, graphr(c(white)) col(3) name(row1, replace)
gr combine ind_p61p80 ind_p81p100, graphr(c(white)) col(2) graphregion(margin(l+40 r+40)) name(row2, replace)
gr combine row1 row2, graphr(c(white)) col(1) ysize(2.5) title("", size(small) color(black) nobox) note("Years since transition into entrepreneurship or pseudo-start", pos(6) size(small)) name(figB2, replace)
gr drop ind_p1p20 ind_p21p40 ind_p41p60 ind_p61p80 ind_p81p100 row1 row2
graph export "$figs\figB2.eps", as(eps) preview(off) replace

/*
Figure B3: Differences in income trajectories between entrepreneurs and wage earners by individual and parental income: Market income with retained earnings
*/

use "$output\04_incomemobility\figB3", clear
foreach var of varlist b1_ie-se25_we {
	gen `var'_m1=`var'[5]
}
foreach var of varlist b1_ie-se25_we {
	replace `var'=`var'-`var'_m1
}
drop *m1

* Point estimates
forval i= 1(1)25{
	gen diff_`i'=b`i'_ie-b`i'_we
}

* Confidence intervals
forval i= 1(1)25{
	gen lo_`i'_ie=b`i'_ie-1.96*se`i'_ie
	gen up_`i'_ie=b`i'_ie+1.96*se`i'_ie
	gen lo_`i'_we=b`i'_we-1.96*se`i'_we
	gen up_`i'_we=b`i'_we+1.96*se`i'_we
}
forval i= 1(1)25{
	gen diff_lo_`i'=lo_`i'_ie-lo_`i'_we
	gen diff_up_`i'=up_`i'_ie-up_`i'_we
}

* Make some room in the timeline
gen event_b=event-0.1
gen event_t=event+0.1

* Individual: P1-P20
twoway rcap diff_lo_1 diff_up_1 event_b, col(gs6) || scatter diff_1 event_b, mc(gs6) ms(sh) || line diff_1 event_b, lc(gs6) lp(solid) || line diff_2 event, lc(gs12) lp(solid) || scatter diff_2 event, mc(gs12) ms(x) || scatter diff_3 event, mc(gs12) ms(x) || scatter diff_4 event, mc(gs12) ms(x) || line diff_3 event, lc(gs12) lp(solid) || line diff_4 event, lc(gs12) lp(solid) || rcap diff_lo_5 diff_up_5 event_t, col(gs6) || scatter diff_5 event_t, mc(gs2) ms(d) || line diff_5 event_t, lc(gs2) lp(solid) || , graphr(c(white)) scheme(s2mono) title("{it:Individual P1-P20}", size(medium) color(black) nobox) ytitle("{it:IE-WE (log income)}", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) xtitle("", size(medium)) xtitle(, color(black)) xlabel(-5(1)10) ysc(range(-0.4 0.8)) ylabel(-0.4(0.2)0.8, angle(0)) aspect(0.6) legend(order(2 "Parent P1-P20" 5 "Parent P21-P80" 11 "Parent P81-P100") region(style(none)) cols(1) ring(0) bplace(seast) rowg(0.1)) name(ind_p1p20, replace)
* Individual: P21-P40
twoway rcap diff_lo_6 diff_up_6 event_b, col(gs6) || scatter diff_6 event_b, mc(gs6) ms(sh) || line diff_6 event_b, lc(gs6) lp(solid) || line diff_7 event, lc(gs12) lp(solid) || scatter diff_7 event, mc(gs12) ms(x) || scatter diff_8 event, mc(gs12) ms(x) || scatter diff_9 event, mc(gs12) ms(x) || line diff_8 event, lc(gs12) lp(solid) || line diff_9 event, lc(gs12) lp(solid) || rcap diff_lo_10 diff_up_10 event_t, col(gs6) || scatter diff_10 event_t, mc(gs2) ms(d) || line diff_10 event_t, lc(gs2) lp(solid) || , graphr(c(white)) scheme(s2mono) title("{it:Individual P21-P40}", size(medium) color(black) nobox) ytitle("{it:IE-WE (log income)}", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) xtitle("", size(medium)) xtitle(, color(black)) xlabel(-5(1)10) ysc(range(-0.4 0.8)) ylabel(-0.4(0.2)0.8, angle(0)) aspect(0.6) legend(order(2 "Parent P1-P20" 5 "Parent P21-P80" 11 "Parent P81-P100") region(style(none)) cols(1) ring(0) bplace(seast) rowg(0.1)) name(ind_p21p40, replace)
* Individual: P41-P60
twoway rcap diff_lo_11 diff_up_11 event_b, col(gs6) || scatter diff_11 event_b, mc(gs6) ms(sh) || line diff_11 event_b, lc(gs6) lp(solid) || line diff_12 event, lc(gs12) lp(solid) || scatter diff_12 event, mc(gs12) ms(x) || scatter diff_13 event, mc(gs12) ms(x) || scatter diff_14 event, mc(gs12) ms(x) || line diff_13 event, lc(gs12) lp(solid) || line diff_14 event, lc(gs12) lp(solid) || rcap diff_lo_15 diff_up_15 event_t, col(gs6) || scatter diff_15 event_t, mc(gs2) ms(d) || line diff_15 event_t, lc(gs2) lp(solid) || , graphr(c(white)) scheme(s2mono) title("{it:Individual P41-P60}", size(medium) color(black) nobox) ytitle("{it:IE-WE (log income)}", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) xtitle("", size(medium)) xtitle(, color(black)) xlabel(-5(1)10) ysc(range(-0.4 0.8)) ylabel(-0.4(0.2)0.8, angle(0)) aspect(0.6) legend(order(2 "Parent P1-P20" 5 "Parent P21-P80" 11 "Parent P81-P100") region(style(none)) cols(1) ring(0) bplace(seast) rowg(0.1)) name(ind_p41p60, replace)
* Individual: P61-P80
twoway rcap diff_lo_16 diff_up_16 event_b, col(gs6) || scatter diff_16 event_b, mc(gs6) ms(sh) || line diff_16 event_b, lc(gs6) lp(solid) || line diff_17 event, lc(gs12) lp(solid) || scatter diff_17 event, mc(gs12) ms(x) || scatter diff_18 event, mc(gs12) ms(x) || scatter diff_19 event, mc(gs12) ms(x) || line diff_18 event, lc(gs12) lp(solid) || line diff_19 event, lc(gs12) lp(solid) || rcap diff_lo_20 diff_up_20 event_t, col(gs6) || scatter diff_20 event_t, mc(gs2) ms(d) || line diff_20 event_t, lc(gs2) lp(solid) || , graphr(c(white)) scheme(s2mono) title("{it:Individual P61-P80}", size(medium) color(black) nobox) ytitle("{it:IE-WE (log income)}", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) xtitle("", size(medium)) xtitle(, color(black)) xlabel(-5(1)10) ysc(range(-0.4 0.8)) ylabel(-0.4(0.2)0.8, angle(0)) aspect(0.6) legend(order(2 "Parent P1-P20" 5 "Parent P21-P80" 11 "Parent P81-P100") region(style(none)) cols(1) ring(0) bplace(seast) rowg(0.1)) name(ind_p61p80, replace)
* Individual: P81-P100
twoway rcap diff_lo_21 diff_up_21 event_b, col(gs6) || scatter diff_21 event_b, mc(gs6) ms(sh) || line diff_21 event_b, lc(gs6) lp(solid) || line diff_22 event, lc(gs12) lp(solid) || scatter diff_22 event, mc(gs12) ms(x) || scatter diff_23 event, mc(gs12) ms(x) || scatter diff_24 event, mc(gs12) ms(x) || line diff_23 event, lc(gs12) lp(solid) || line diff_24 event, lc(gs12) lp(solid) || rcap diff_lo_25 diff_up_25 event_t, col(gs6) || scatter diff_25 event_t, mc(gs2) ms(d) || line diff_25 event_t, lc(gs2) lp(solid) || , graphr(c(white)) scheme(s2mono) title("{it:Individual P81-P100}", size(medium) color(black) nobox) ytitle("{it:IE-WE (log income)}", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) xtitle("", size(medium)) xtitle(, color(black)) xlabel(-5(1)10) ysc(range(-0.4 0.8)) ylabel(-0.4(0.2)0.8, angle(0)) aspect(0.6) legend(order(2 "Parent P1-P20" 5 "Parent P21-P80" 11 "Parent P81-P100") region(style(none)) cols(1) ring(0) bplace(seast) rowg(0.1)) name(ind_p81p100, replace)

* Combine
gr combine ind_p1p20 ind_p21p40 ind_p41p60, graphr(c(white)) col(3) name(row1, replace)
gr combine ind_p61p80 ind_p81p100, graphr(c(white)) col(2) graphregion(margin(l+40 r+40)) name(row2, replace)
gr combine row1 row2, graphr(c(white)) col(1) ysize(2.5) title("", size(small) color(black) nobox) note("Years since transition into entrepreneurship or pseudo-start", pos(6) size(small)) name(figB3, replace)
gr drop ind_p1p20 ind_p21p40 ind_p41p60 ind_p61p80 ind_p81p100 row1 row2
graph export "$figs\figB3.eps", as(eps) preview(off) replace

/*
Figure B4: Disposable income trajectories using a balanced panel of individuals
*/

use "$output\04_incomemobility\figB4", clear
merge 1:1 nro using "$output\04_incomemobility\fig4", keepusing(base lvl_ie)
gen nro_ie=nro+0.1
gen nro_we=nro-0.1
order nro nro_ie nro_we

twoway scatter base nro_we, mc(gs10) msymbol(oh) graphr(c(white)) scheme(s2mono) ytitle("Log income", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) title("{it:Panel A: Baseline}", size(medsmall) color(black) nobox) xtitle("", size(medium)) xtitle(, color(black)) legend(ring(0) rowg(0.25) bplace(seast)) ysize(3.5) name(A, replace)
addplot A: line base nro_we, lc(gs10) lp(solid) 
addplot A: scatter lvl_ie nro_ie, mc(maroon) msymbol(sh)
addplot A: line lvl_ie nro_ie, lc(maroon) lp(solid) xlabel(-5(1)10) ysc(range(-0.31 0.75)) ylabel(-0.25(0.25)0.75, angle(0)) legend(order(3 "Entrepreneurs" 1 "Wage earners") cols(1) size(small))

twoway scatter base_bal_m1p10 nro_we, mc(gs10) msymbol(oh) graphr(c(white)) scheme(s2mono) ytitle("Log income", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) title("{it:Panel B: Balanced from t-1 to t+10}", size(medsmall) color(black) nobox) xtitle("", size(medium)) xtitle(, color(black)) legend(ring(0) rowg(0.25) bplace(seast)) ysize(3.5) name(B, replace)
addplot B: line base_bal_m1p10 nro_we, lc(gs10) lp(solid) 
addplot B: scatter lvl_ie_bal_m1p10 nro_ie, mc(maroon) msymbol(sh)
addplot B: line lvl_ie_bal_m1p10 nro_ie, lc(maroon) lp(solid) xlabel(-5(1)10) ysc(range(-0.31 0.75)) ylabel(-0.25(0.25)0.75, angle(0)) legend(order(3 "Entrepreneurs" 1 "Wage earners") cols(1) size(small))

twoway scatter base_bal_m1p10 nro_we, mc(gs10) msymbol(oh) graphr(c(white)) scheme(s2mono) ytitle("Log income", size(medsmall)) ytitle(, color(black)) xline(0, lp(dash)) title("{it:Panel C: Fully balanced panel}", size(medsmall) color(black) nobox) xtitle("", size(medium)) xtitle(, color(black)) legend(ring(0) rowg(0.25) bplace(seast)) ysize(3.5) name(C, replace)
addplot C: line base_bal_m1p10 nro_we, lc(gs10) lp(solid) 
addplot C: scatter lvl_ie_bal_m1p10 nro_ie, mc(maroon) msymbol(sh)
addplot C: line lvl_ie_bal_m1p10 nro_ie, lc(maroon) lp(solid) xlabel(-5(1)10) ysc(range(-0.31 0.75)) ylabel(-0.25(0.25)0.75, angle(0)) legend(order(3 "Entrepreneurs" 1 "Wage earners") cols(1) size(small))

gr combine A B C, graphr(c(white)) col(1) ysize(7.5) note("Years since transition into entrepreneurship or pseudo-start", pos(6) size(small)) name(figB4, replace)
gr drop A B C
graph export "$figs\figB4.eps", as(eps) preview(off) replace

/*
Figure B5: Gains in disposable income by industry of the new incorporated business
*/

use "$output\04_incomemobility\figB5", clear

* For the x-axis
drop if ind=="Constant"
rename ind ind_str
gen indraw=_n
gen indctrl=_n+0.1
order ind_str indraw indctrl
label define indraw_lbl 1 "Forestry and logging (2)" 2 "Mining and quarrying (8)" 3 "Manufacture of food products (10)" 4 "Manufacture of textiles (13)" 5 "Manufacture of wood and wood products (16)" 6 "Printing and reproduction of recorded media (18)" 7 "Manufacture of rubber and plastic products (22)" 8 "Manufacture of other non-metallic mineral products (23)" 9 "Manufacture of fabricated metal products (25)" 10 "Manufacture of computer, electronic and optical products (26)" 11 "Manufacture of electrical equipment (27)" 12 "Manufacture of machinery and equipment n.e.c. (28)" 13 "Manufacture of motor vehicles, trailers and semi-trailers (29)" 14 "Manufacture of other transport equipment (30)" 15 "Manufacture of furniture (31)" 16 "Other manufacturing (32)" 17 "Repair and installation of machinery and equipment (33)" 18 "Electricity, gas, steam and air conditioning supply (35)" 19 "Waste collection, treatment and disposal activities (38)" 20 "Construction of buildings (41)" 21 "Civil engineering (42)" 22 "Specialised construction activities (43)" 23 "Wholesale and retail trade and repair of motor vehicles (45)" 24 "Wholesale trade, except of motor vehicles (46)" 25 "Retail trade, except of motor vehicles (47)" 26 "Land transport and transport via pipelines (49)" 27 "Water transport (50)" 28 "Warehousing and support activities for transportation (52)" 29 "Accommodation (55)" 30 "Food and beverage service activities (56)" 31 "Publishing activities (58)" 32 "Movie and TV programme and music publishing activities (59)" 33 "Programming and broadcasting activities (60)" 34 "Telecommunications (61)" 35 "Computer programming, consultancy and related activities (62)" 36 "Information service activities (63)" 37 "Financial services, except insurance and pension funding (64)" 38 "Activities auxiliary to financial services and insurance activities (66)" 39 "Real estate activities (68)" 40 "Legal and accounting activities (69)" 41 "Activities of head offices; management consultancy activities (70)" 42 "Architectural and engineering activities (71)" 43 "Scientific research and development (72)" 44 "Advertising and market research (73)" 45 "Other professional, scientific and technical activities (74)" 46 "Veterinary activities (75)" 47 "Rental and leasing activities (77)" 48 "Employment activities (78)" 49 "Travel agency, tour operator and related activities (79)" 50 "Security and investigation activities (80)" 51 "Services to buildings and landscape activities (81)" 52 "Office administrative and support activities (82)" 53 "Education (85)" 54 "Human health activities (86)" 55 "Residential care activities (87)" 56 "Social work activities without accommodation (88)" 57 "Creative, arts and entertainment activities (90)" 58 "Sports activities and amusement and recreation activities (93)" 59 "Repair of computers and personal and household goods (95)" 60 "Other personal service activities (96)"
label values indraw indraw_lbl
replace indraw=indraw-0.1

* CIs
foreach var of varlist raw ctrl {
	gen `var'_lo=.
	gen `var'_up=.
	replace `var'_lo = `var' - 1.96*`var'_se
	replace `var'_up = `var' + 1.96*`var'_se
}

* Plot
twoway rcap raw_lo raw_up indraw, col(gs9) || scatter raw indraw, mc(gs9) msymbol(sh) || , graphr(c(white)) scheme(s2mono) ysize(2.75) ytitle("Log income", size(medium)) ytitle(, color(black)) xtitle("", size(medium)) xtitle(, color(black)) legend(ring(0) bplace(neast)) name(figB5, replace)
addplot figB5: rcap ctrl_lo ctrl_up indctrl, col(gs2) || scatter ctrl indctrl, mc(gs2) msymbol(d) || , ysc(range(-0.4 1.65)) ylabel(-0.4(0.4)1.6, angle(0)) xlabel(1(1)60, valuelabel angle(45) labsize(vsmall) grid) legend(order(2 "Raw data" 4 "With controls") region(style(none)) cols(2))

graph export "$figs\figB5.eps", as(eps) preview(off) replace
